package fr.emn.integration.synthese.controle;

import java.util.Observable;
import java.util.Observer;
import java.util.Vector;

import javax.swing.JList;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import fr.emn.integration.synthese.abstraction.Cours;

public class ControlJListNonInscrit implements ListSelectionListener, Observer {

		private Cours modele;
		private JList<String> listeModuleNonInscrit;
		
	public ControlJListNonInscrit(Cours modele,
			JList<String> listeModuleNonInscrit) {
		this.modele = modele;
		this.listeModuleNonInscrit = listeModuleNonInscrit;
	}

	@Override
	public void update(Observable o, Object message) {
		Integer iMessage = (Integer) message;
		if (iMessage == Cours.CHANGEMENT_ELEVES_GROUPE) {
			Vector<String> data2 = modele.findNonModuleEleve(modele.getEleveCourante());
			if (data2!=null) {
				listeModuleNonInscrit.setListData(data2);
				}
			else {
				listeModuleNonInscrit = new JList<String>();
		}
			this.listeModuleNonInscrit.repaint();
	}


	}

	@Override
	public void valueChanged(ListSelectionEvent e) {
			this.modele.changementSelectionListeInscritouNon();
		
	}

}
